package com.gotokeep.gyromousedemo

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity

class ReceiverActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_receiver)
        initView()
    }

    private fun initView() {
        findViewById<LinearLayout>(R.id.root).apply {
            for (i in 0 until childCount) {
                val child = getChildAt(i)
                child.setOnClickListener {
                    Log.e(TAG, "onClick......")
                    Toast.makeText(applicationContext, "点击事件...", Toast.LENGTH_SHORT).show()
                }
                child.setOnLongClickListener {
                    Log.e(TAG, "onLongClick......")
                    Toast.makeText(applicationContext, "长按事件...", Toast.LENGTH_SHORT).show()
                    true
                }
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        stopService(Intent(this, ServerService::class.java))
    }

    companion object {

        private const val TAG = "ReceiverActivity"
    }
}
